package be.idamf.flash.system
{
	import flash.system.ApplicationDomain;
	import flash.utils.ByteArray;

	public class PerformanceTest
	{
		public static const SIZE:uint = ApplicationDomain.MIN_DOMAIN_MEMORY_LENGTH * 1024;
		
		public function PerformanceTest()
		{
		}
		
		[Test]
		public function test_as3():void
		{
			var address:int;
			var bytes:ByteArray = new ByteArray();
			bytes.length = SIZE;
			
			for (address = 0; address < SIZE; ++address)
				bytes.writeByte(address);
			
			bytes.position = 0;

			for (address = 0; address < SIZE; ++address)
				bytes.readByte();
		}

		[Test]
		public function test_haxe():void
		{
			var address:int;
			var bytes:ByteArray = new ByteArray();
			bytes.length = SIZE;
			
			Memory.select(bytes);
			
			for (address = 0; address < SIZE; ++address)
				Memory.writeByte(address, address);
			
			for (address = 0; address < SIZE; ++address)
				Memory.readByte(address);
		}

		[Test]
		public function test_haxe_inline():void
		{
			InlineTest.test();
		}
	}
}